function[] = applyPerceptronToBool()
% Runs perco function with AND, OR and XOR and displays results.
    
    X = [0 0 1 1; 0 1 0 1];
    figure;
    
    % OR
    t = [0 1 1 1];
    w = perco(X, t, 6);
    subplot(2,2,1);
    gscatter(X(1,:), X(2,:), t);
    hold on;
    func = [num2str(w(2)) ' * x + ' num2str(w(3)) ' * y - ' num2str(-w(1))];
    ezplot(func);
    
    suffix = '';
    if (~w(4))
        suffix = ' - did not converge';
    end
    title(['OR' suffix]);
    
    % AND
    t = [0 0 0 1];
    w = perco(X, t, 9);
    subplot(2,2,2);
    gscatter(X(1,:), X(2,:), t);
    hold on;
    func = [num2str(w(2)) ' * x + ' num2str(w(3)) ' * y - ' num2str(-w(1))];
    ezplot(func);
    
    suffix = '';
    if (~w(4))
        suffix = ' - did not converge';
    end
    title(['AND' suffix]);
    
    % XOR
    t = [0 1 1 0];
    w = perco(X, t, 50);
    subplot(2,2,3);
    gscatter(X(1,:), X(2,:), t);
    if w(2) ~= 0 || w(3) ~= 0
        hold on;
        func = [num2str(w(2)) ' * x + ' num2str(w(3)) ' * y - ' num2str(-w(1))];
        ezplot(func);
    end
    
    suffix = '';
    if (~w(4))
        suffix = ' - did not converge';
    end
    title(['XOR' suffix]);
end
